package  
{
	import org.flixel.*;
	/**
	 * ...
	 * @author Andrew Tolver
	 */
	public class LightningSparks extends FlxSprite
	{
		
		public function LightningSparks(X:Number = 0, Y:Number = 0, SimpleGraphic:Class = null) 
		{
			super(X, Y, SimpleGraphic);
		}		
		
		//reverse direction when hit floor, with variation
		override public function hitBottom(Contact:FlxObject, Velocity:Number):void
		{
			if (velocity.y > 0)
			{
				velocity.y = -(velocity.y / ((Math.random() % 5) + 2)) - Math.random() * 20;
			}
		}
		
		//reverse direction when hit ceiling, with variation
		override public function hitTop(Contact:FlxObject, Velocity:Number):void
		{
			if (velocity.y < 0)
			{
				velocity.y = -(velocity.y / ((Math.random() % 5) + 2)) + Math.random() * 20;
			}
		}
		
		//reverse direction when hit wall on left, with variation
		override public function hitLeft(Contact:FlxObject, Velocity:Number):void
		{
			if (velocity.x < 0)
			{
				velocity.x = -(velocity.x / ((Math.random() % 5) + 2)) + Math.random() * 20;
			}
		}
		
		//reverse direction when hit wall on right, with variation
		override public function hitRight(Contact:FlxObject, Velocity:Number):void
		{
			if (velocity.x > 0)
			{
				velocity.x = -(velocity.x / ((Math.random() % 5) + 2)) - Math.random() * 20;
			}
		}
		
		override public function update():void
		{
			if (velocity.y > -1 && velocity.y < 1)
			{
				this.kill();
			}
			
			super.update();
		}
		
	}

}